package dp;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Scanner;

public class 数字三角形 {
    static int[][] dp;

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        dp = new int[n + 1][n + 1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++) {
                int num = scanner.nextInt();
                dp[i][j] = num;

            }
        }

        for (int i = 1; i <= dp.length - 1; i++) {
            for (int j = 1; j <= i; j++) {
                dp[i][j] = dp[i][j] + Math.max(dp[i - 1][j - 1], dp[i - 1][j]);

            }
        }

        if (n % 2 == 0) { //偶数
            System.out.println(Integer.max(dp[n][n / 2], dp[n][n / 2 + 1]));
        } else { //奇数
            System.out.println(dp[n][n / 2 + 1]);
        }
//        print(dp);
    }

    private static void print(int[][] map) {
        System.out.println("====");
        for (int[] line : map) {
            System.out.println(Arrays.toString(line));
        }
        System.out.println("====");
    }
}
